#Author: Tanyong
# *-* coding:utf8 *-*
# @time       : 2018/7/26 8:53
# @Author     : Tanyong
# @Site       : 
# @File       : __init__.py.py
# @Software   : PyCharm
from flask import Blueprint
from flask import redirect
from flask import request
from flask import session
from flask import url_for


admin_blu = Blueprint("admin", __name__)

from . import views

@admin_blu.before_request
def check_admin():
    """检查管理员身份"""
    if not request.url.endswith(url_for('admin.login')):
        user_id = session.get('user_id')
        is_admin = session.get('is_admin', False)

        if not user_id or not is_admin:
            return redirect('/')

